package com.dongzili.common.entity;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.yulichang.annotation.EntityMapping;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;

import java.util.List;

/**
 * 用户基本信息
 */
@DS("main")
@Data
@FieldNameConstants
@Accessors(chain = true)
@TableName("t_user")
public class User {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String username;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @TableField(value = "roleIds")
    private List<Integer> roleIds;

    @TableField(exist = false)
    @EntityMapping(thisField = "roleIds", joinField = "id")
    private List<Role> roles;

    @TableField(exist = false)
    private List<String> roleCodes;

}
